
const app = getApp()
Page({
    data: {
        ipTotalPage: 0,
        ipPageNum: 1,
        ip_list: [],
        guestTotalPage: 0,
        guestPageNum: 1,
        guest_list: [],
    },
    onShow: function () {
        this.setData({
            ip_list:[],
            guest_list:[]
        })
        this.getGuestList()
        this.getIpList()
    },
    onLoad() {
        wx.showShareMenu({
          withShareTicket: true,
        })
      },
      onShareTimeline() {
        return {
          title: '梦与玩',
          query: 'pages/market/market-index'
        }
      },
      onShareAppMessage() {
        return {
          title: '梦与玩'
        }
      },
    getIpList() {
        let _this = this;
        app.util.request({
            url: "api/type/findLimit",
            method: "post",
            data: {
                state: 0,
                page: _this.data.ipPageNum,
                pageSize: 100,
            },
            success(response) {
                if (response.data.code == 0) {
                    _this.setData({
                        ipTotalPage: response.data.data.pages,
                        ip_list: [..._this.data.ip_list, ...response.data.data.list]
                    })
                    if (_this.data.ipPageNum < response.data.data.pages) {
                        _this.data.ipPageNum = _this.data.ipPageNum + 1
                        _this.getIpList()
                    }
                }
            }
        })
    },
    getGuestList() {
        let _this = this;
        app.util.request({
            url: "api/type/findLimit",
            method: "post",
            data: {
                state: 1,
                page: _this.data.guestPageNum,
                pageSize: 100,
            },
            success(response) {
                if (response.data.code == 0) {
                    _this.setData({
                        guestTotalPage: response.data.data.pages,
                        guest_list: [..._this.data.guest_list, ...response.data.data.list]
                    })

                }
            }
        })
    },
    toSearch(){
        wx.navigateTo({
            url: '/pages/market/search-page/search-page',
        })
    },
    toMarketCategory(e) {
        wx.navigateTo({
            url: '/pages/market/market-categoty-list/market-categoty-list?id=' + e.currentTarget.dataset.id,
        })
    },
    toDetail(e) {
        wx.navigateTo({
            url: '/pages/goods/goods-detail/goods-detail?id=' + e.currentTarget.dataset.id,
        })
    }
})